package com.ziven.common.widget.value;

import android.view.View;

import androidx.annotation.NonNull;

import com.ziven.easygo.util.EasyUtils;
import com.ziven.easygo.util.ViewHelper;

import java.util.List;

/**
 * @author Ziven
 */
public final class StringValue extends Value {

    public static StringValue value(String string) {
        return new StringValue(string);
    }

    public static StringValue[] values(String... strings) {
        if(strings == null || strings.length == 0) {
            return new StringValue[0];
        }
        StringValue[] values = new StringValue[strings.length];
        EasyUtils.forEach(strings, (string, position) -> values[position] = value(string));
        return values;
    }

    public static StringValue[] values(List<String> strings) {
        if(strings == null || strings.isEmpty()) {
            return new StringValue[0];
        }
        StringValue[] values = new StringValue[strings.size()];
        EasyUtils.forEach(strings, (string, position) -> values[position] = value(string));
        return values;
    }

    private StringValue(String str) {
        if(!EasyUtils.isEmpty(str)) {
            value = str;
        } else {
            value = EasyUtils.EMPTY;
        }
    }

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        //Do nothing
    }
}
